package com.origon.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;

import java.util.List;
import java.util.UUID;
import static javax.persistence.CascadeType.ALL;


/**
 * The persistent class for the shop database table.
 * 
 */
@Entity
public class Shop implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String id;

	private Boolean bankTransfer;

	private Boolean creditCard;

	private String description;

	private String name;

	private Boolean payPal;

	private String shopNumber;

	//bi-directional many-to-one association to Product
	@OneToMany(mappedBy="shop")
	private List<Product> products;

	//bi-directional many-to-one association to Account
	@ManyToOne(fetch = FetchType.LAZY, cascade=ALL)
	@JoinColumn(name="AccountId")
	private Account account;

	//bi-directional many-to-one association to Address
	@ManyToOne(fetch = FetchType.LAZY, cascade=ALL)
	@JoinColumn(name="BillingAddressId")
	private Address billingAddress;

	//bi-directional many-to-one association to Address
	@ManyToOne(fetch = FetchType.LAZY, cascade=ALL)
	@JoinColumn(name="ShippingAddressId")
	private Address shippingAddress;

	//bi-directional many-to-one association to Category
	@ManyToOne
	@JoinColumn(name="CategoryId")
	private Category category;

	//bi-directional many-to-one association to Country
	@ManyToOne
	@JoinColumn(name="LocationId")
	private Country country;

	//bi-directional many-to-one association to Currency
	@ManyToOne
	@JoinColumn(name="CurrencyId")
	private Currency currency;

	//bi-directional many-to-one association to Keeper
	@ManyToOne(fetch = FetchType.LAZY, cascade=ALL)
	@JoinColumn(name="KeeperId")
	private Keeper keeper;

	

	//bi-directional many-to-one association to User
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="OwnerId")
	@NotNull
	private User user;


	public Shop() {
		setId(UUID.randomUUID().toString());
	}
	
	public Shop(User user) {
		setId(UUID.randomUUID().toString());
		this.user = user;
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Boolean getBankTransfer() {
		return this.bankTransfer;
	}

	public void setBankTransfer(Boolean bankTransfer) {
		this.bankTransfer = bankTransfer;
	}

	public Boolean getCreditCard() {
		return this.creditCard;
	}

	public void setCreditCard(Boolean creditCard) {
		this.creditCard = creditCard;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Boolean getPayPal() {
		return this.payPal;
	}

	public void setPayPal(Boolean payPal) {
		this.payPal = payPal;
	}

	public String getShopNumber() {
		return this.shopNumber;
	}

	public void setShopNumber(String shopNumber) {
		this.shopNumber = shopNumber;
	}

	public List<Product> getProducts() {
		return this.products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	
	public Account getAccount() {
		return this.account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	
	public Address getBillingAddress() {
		return billingAddress;
	}

	public void setBillingAddress(Address billingAddress) {
		this.billingAddress = billingAddress;
	}

	public Address getShippingAddress() {
		return shippingAddress;
	}

	public void setShippingAddress(Address shippingAddress) {
		this.shippingAddress = shippingAddress;
	}

	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public Country getCountry() {
		return this.country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public Currency getCurrency() {
		return this.currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public Keeper getKeeper() {
		return this.keeper;
	}

	public void setKeeper(Keeper keeper) {
		this.keeper = keeper;
	}

	

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

		
	@Override
	public String toString() {
		return this.name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((bankTransfer == null) ? 0 : bankTransfer.hashCode());
		result = prime * result
				+ ((creditCard == null) ? 0 : creditCard.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((payPal == null) ? 0 : payPal.hashCode());
		result = prime * result
				+ ((shopNumber == null) ? 0 : shopNumber.hashCode());
		
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Shop other = (Shop) obj;
		if (bankTransfer == null) {
			if (other.bankTransfer != null)
				return false;
		} else if (!bankTransfer.equals(other.bankTransfer))
			return false;
		if (creditCard == null) {
			if (other.creditCard != null)
				return false;
		} else if (!creditCard.equals(other.creditCard))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (payPal == null) {
			if (other.payPal != null)
				return false;
		} else if (!payPal.equals(other.payPal))
			return false;
		if (shopNumber == null) {
			if (other.shopNumber != null)
				return false;
		} else if (!shopNumber.equals(other.shopNumber))
			return false;
		
		return true;
	}
	
	

}